<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAttachmentsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attachments', function (Blueprint $table) {
            $table->increments('id');
            $table->string('original_name')->comment('原始文件名');
            $table->string('store_name')->comment('存储文件名');
            $table->string('extension')->comment('拓展名称');
            $table->string('size')->comment('文件大小');
            $table->string('mime_type')->comment('互联网媒体类型');
            $table->string('type')->comment('文件类型');
            $table->string('from_table')->comment('文件归属表');
            $table->string('from_field')->comment('文件归属字段');
            $table->unsignedInteger('from_id')->comment('文件归属表ID');
            $table->string('data_scope')->nullable()->comment('数据域');
            $table->timestamps();

            $table->comment = '附件表';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attachments');
    }

}
